<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        //全选
        function checkAll(){
            //document.getElementsByTagName("input");是按照标签名来进行查询并返回集合
            //这个集合的操作跟数组 一样，集合中都是dom对象，并且元素顺序从上到下
            let inputs = document.getElementsByTagName("input");
            for (let i = 0; i < inputs.length; i++) {
                inputs[i].checked = true;
            }
        }
    </script>
</head>
<body>
    兴趣爱好:
    <input type="checkbox"  value="cpp" >C++
    <input type="checkbox"  value="cpp" >Java
    <input type="checkbox"  value="cpp" >JS
    <br>
    <button onclick="checkAll()">全选</button>
</body>
</html>